package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Sign;
import cn.wolfcode.trip.base.domain.TransactionRecord;
import cn.wolfcode.trip.base.service.ISignService;
import cn.wolfcode.trip.base.service.ITransactionRecordService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("exchanges")
public class ExchangeController {

    @Autowired
    private ISignService signService;

    @Autowired
    private ITransactionRecordService transactionRecordService;

    /**
     * 获取当前用户的积分
     * @return
     */
    @GetMapping
    @ResponseBody
    public Sign getPointByUserId(){
        return signService.getPointByUserId();
    }

    /**
     * 保存交易记录
     * @param transactionRecord
     * @return
     */
    @PostMapping
    public JSONResult save(TransactionRecord transactionRecord){
        transactionRecordService.save(transactionRecord);
        return new JSONResult();
    }
}
